//用队列实现栈
import StackAndQuene.PersonalQuene;

public class Quene {
    public void push(PersonalQuene q,int num){
        if(this.is_empty(q)){//如果栈满了
            return;
        }
        q.enQuene(num);
    }
    public Boolean is_empty(PersonalQuene q){
        return q.is_empty();
    }
    public Integer pop(PersonalQuene q){
        int length = q.size();
        while (length!=1){
            Integer temp = q.dequene();
            q.enQuene(temp);
            length--;
        }
        return q.dequene();
    }
    public Integer top(PersonalQuene q){
        int length = q.size();
        Integer res = null;
        while (length!=0){
            Integer temp = q.dequene();
            q.enQuene(temp);
            length--;
            if(length==1){
                res = q.getHead();
            }
        }
        return res;
    }
    public static void main(String[] args) {
        var quene = new PersonalQuene(6);
        var main = new Quene();
        quene.enQuene(10);
        quene.enQuene(20);
//        main.pop(quene);
        System.out.println(main.top(quene));
    }
}
